<div ng-controller="contractListCtrl">
    <div class="table-header table-header-border clearfix ng-scope">
        <span class="fl lh30 f14">合同管理</span>
    </div>

    <my-nav data-nav-items="filterDataStatus" onchanged="changeStatus" data-title="合同状态:"></my-nav>
    <!--<my-nav data-nav-items="filterDataCategory" onchanged="changeCategory" data-title="合同大类:"></my-nav>-->
    <my-nav ng-if="userAuthList.indexOf('1701') !== -1 && userAuthList.indexOf('1702') !== -1" data-nav-items="filterDataCategory" onchanged="changeCategory" data-title="合同大类:"></my-nav>
    <my-nav ng-if="userAuthList.indexOf('1701') !== -1 && userAuthList.indexOf('1702') === -1" data-nav-items="filterDataCategoryForAD" onchanged="changeCategory" data-title="合同大类:"></my-nav>
    <my-nav ng-if="userAuthList.indexOf('1701') === -1 && userAuthList.indexOf('1702') !== -1" data-nav-items="filterDataCategoryForSAAS" onchanged="changeCategory" data-title="合同大类:"></my-nav>
    <my-nav data-nav-items="filterDataNature" onchanged="changeNature" data-title="合同性质:"
            data-text-field="property_name"></my-nav>
    <my-nav data-nav-items="filterDataCities" onchanged="changeCity" data-title="城市区域:" data-text-field="areaName"
            need-more="true"></my-nav>
    <my-nav data-nav-items="filterTimeType" onchanged="changeTimeType" data-title="时间类型:"></my-nav>
    <my-nav data-nav-items="filterStatementType" onchanged="changeStatement" data-title="报表类型:"></my-nav>


    <div class="table-header lh30 mt20 clearfix ng-scope">
        <span class="fl lh30 f14">合同列表</span>
        <div class="fr btn-group" ng-init="downloadUrl=''">
            <a ng-if="(showTimeSelected || 0) != 0">
                <span class="fl">时间：</span>
                <input type="text" class="fl input-text w120 ml3 input-date" ng-model="query.beginDate"
                       ng-enter="query.execute()" ui-date format="yyyy-MM-dd">
                <span class="fl ml3">-</span>
                <input type="text" class="fl input-text w120 ml3 input-date" ng-model="query.endDate"
                       ng-enter="query.execute()" ui-date format="yyyy-MM-dd">
            </a>
            <input class="input-text fl w200 ml3" style="width: 470px;" type="text"
                   placeholder="公司/合同编号/客户全称/出库单号/ERP合同编号/会签单号"
                   ng-model="query.keyword"
                   ng-enter="query.execute()"/>
            <a class="btn" href="javascript: void(0)"
               ng-click="query.execute()">查询</a>
            <a class="btn" href="/contract/edit.shtml#base" target="_blank"
               ng-if="userAuthList.indexOf('0001') !== -1">新建合同</a>
            <a class="btn btn-yellow" href="javascript:;" ng-click="downloadExcel($event)"
               ng-if="userAuthList.indexOf('0003') !== -1">导出excel</a>
            <div  id="fileupload" class="fileinput-button btn btn-yellow"
                  ng-if="userAuthList.indexOf('0003') !== -1">
                <span class="f13">导入返款</span>
                <input type="file" name="file" accept=".xls,.xlsx" queueLimit="1">
            </div>
            <a
                    href="javascript:;"
                    class="btn btn-yellow"
                    ui-dialog="导入纸质合同"
                    ui-dialog-data="{}"
                    ui-dialog-show="onExportPaperContractEditShow($dialog, $dialogScope)"
                    ui-dialog-cache="false"
                    ui-dialog-url="/contract/dialog/paper-contract-export.html"
            >
                导入纸质合同
            </a>
        </div>
    </div>

    <div id="grid" class="table-responsive mt10">
        <table class="table table-hover">
            <thead>
            <tr>
                <th width="35">序号</th>
                <th width="150">客户信息</th>
                <th width="190">合同信息</th>
                <th>合同签署公司</th>
                <th width="140">签约信息</th>
                <th width="120">金额信息</th>
                <th width="65">合同状态</th>
                <th width="90">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="record in contracts">
                <td height="40"><p ng-bind="$index + 1 + startPageIndex"></p></td>
                <td class="lh14">
                    <p ng-bind="record.customer_full_name"></p>

                    <p class="tab-text-gray">客户简称:{{record.customer_name}}</p>
                </td>
                <td>
                    <a ng-href="/contract/edit.shtml#/base?id={{record.contract_id}}"
                       ng-style="{color: '#333'}"
                       target="_blank">
                        <p ng-bind="record.contract_code"></p>
                    </a>

                    <p class="tab-text-gray">合同性质:{{record.property_name}}</p>

                    <p class="tab-text-gray">合同类别:{{record.category_name}}</p>

                    <p ng-if="record.beginOn" class="tab-text-gray">
                        租期:{{record.beginOn|strdate:'yyyy-MM-dd'}}至{{record.endOn|strdate:'yyyy-MM-dd'}}
                    </p>
                </td>
                <td>
                    <p ng-bind="record.company_name"></p>

                    <p class="tab-text-gray">所属区域:{{record.area_name}}</p>
                </td>
                <td>
                    <p>签约人:{{record.user_name}}</p>

                    <p class="tab-text-gray">签约日期:{{record.sign_date | strdate: 'yyyy-MM-dd'}}</p>

                    <p class="tab-text-gray">录入日期:{{record.input_date | strdate: 'yyyy-MM-dd'}}</p>
                </td>
                <td>
                    <p>签约金额:{{record.sign_amount | number}}</p>

                    <p class="tab-text-gray">租用金额:{{record.rent_amount | number}}</p>

                    <p class="tab-text-gray">交付金额:{{record.delivery_amount | number}}</p>
                </td>
                <td>
                    <p ng-if="record.contract_status == 0 && record.is_cancelled == 0">草稿</p>

                    <p ng-if="record.contract_status == 1 && record.is_cancelled == 0">提交复核</p>

                    <p ng-if="record.contract_status == 2 && record.is_cancelled == 0">已审核</p>

                    <p ng-if="record.is_cancelled == 1">作废</p>
                </td>
                <td>
                    <div row-toolbar min-buttons-show="8">
                        <a ng-click="submitVerify(record)" class="clearfix tab-text" href="javascript:void(0)"
                           ng-if="record.contract_status==0 && record.is_cancelled == 0 && userAuthList.indexOf('0001') !== -1"
                           title="提交复核">提交复核</a>
                        <a ng-click="cancelVerify(record)" class="clearfix tab-text" href="javascript:void(0)"
                           ng-if="record.contract_status==1 && record.is_cancelled == 0 && userAuthList.indexOf('0001') !== -1"
                           title="撤销复核">撤销复核</a>
                        <a ng-click="confirmVerify(record)" class="clearfix tab-text" href="javascript:void(0)"
                           ng-if="record.contract_status==1 && record.is_cancelled == 0 && userAuthList.indexOf('0002') !== -1"
                           title="复核">复核</a>
                        <a ng-href="/contract/edit.shtml#/base?id={{record.contract_id}}" target="_blank"
                           class="clearfix tab-text" title="编辑合同信息"
                           ng-if="record.contract_status == 0 && record.is_cancelled == 0"
                           title="编辑">编辑</a>
                        <a ng-href="/contract/edit.shtml#/base?id={{record.contract_id}}" target="_blank"
                           class="clearfix tab-text" title="编辑发票、回款信息"
                           ng-if="record.contract_status!=0 || record.is_cancelled == 1"
                        >编辑</a>
                        <a ng-click="cancelContract(record)" class="clearfix tab-text" href="javascript:void(0)"
                           ng-if="record.is_cancelled == 0 && userAuthList.indexOf('0001') !== -1"
                           title="作废">作废</a>
                        <a ng-href="/contract/edit.shtml#/base?pid={{record.contract_id}}" target="_blank"
                           class="clearfix tab-text"
                           ng-if="record.is_cancelled == 0 && userAuthList.indexOf('0001') !== -1"
                           title="新建附属合同">新建附属合同</a>
                        <div ng-if="userAuthList.indexOf('0001') !== -1">
                            <a ng-click="deleteContract(record)" href="javascript:void(0)"
                               class="clearfix tab-text"
                               ng-if="(record.is_cancelled == 1) || (record.contract_status == 0 && record.is_cancelled == 0)"
                               title="删除">删除</a>
                        </div>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="no-data" style="display:none"><span>暂无数据</span></div>
    </div>
    <div id="pagination" class="pagination"></div>
</div>
